import java.text.DecimalFormat;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        List<Person> arr=new ArrayList<>();
        while(true){
            String s=sc.nextLine();
            if(s.startsWith("s")){
                String[] t=s.split(" ");
                arr.add(new Student(t[1],Integer.getInteger(t[2]),Boolean.getBoolean(t[3]),t[4],t[5]));
            }else if(s.startsWith("e")){
                String[] t=s.split(" ");
                arr.add(new Employee(t[1],Integer.parseInt(t[2]),Boolean.parseBoolean(t[3]),new Company(t[4]),Double.parseDouble(t[5]) ));
            }else{
                break;
            }
        }
        Collections.sort(arr,Comparator.comparing(Person::getAge).thenComparing());
    }
}
class Person{
    private String name;
    private int age;
    private boolean gender;

    public Person(String name, int age, boolean gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public boolean isGender() {
        return gender;
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }

    @Override
    public String toString() {
        return name+"-"+age+"-"+gender;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return age == person.age && gender == person.gender && name.equals(person.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, gender);
    }
}
class Student extends Person{
    private String stuNo;
    private String clazz;

    public Student(String name, int age, boolean gender, String stuNo, String clazz) {
        super(name, age, gender);
        this.stuNo = stuNo;
        this.clazz = clazz;
    }

    @Override
    public String toString() {
        return "Student:" +super.toString()+"-"+stuNo+"-"+clazz;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        Student student = (Student) o;
        return stuNo.equals(student.stuNo) && clazz.equals(student.clazz);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), stuNo, clazz);
    }
}
class Company{
    private String name;

    public Company(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Company company = (Company) o;
        return name.equals(company.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }
}
class Employee extends Person{
    private  Company company;
    private double salary;

    public Employee(String name, int age, boolean gender, Company company, double salary) {
        super(name, age, gender);
        this.company = company;
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Employee:"+super.toString()+"-"+company+"-"+salary;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        Employee employee = (Employee) o;
        DecimalFormat df = new DecimalFormat("#.#");
        return df.format(salary).equals(df.format(employee.salary)) && company.equals(employee.company);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), company, salary);
    }
}

